package com.ewzj.bigdata.mvp.ui.activity

import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle

import com.ewzj.bigdata.R
import com.ewzj.bigdata.app.extensions.initcolor
import com.ewzj.bigdata.di.component.DaggerMessageActivityComponent
import com.ewzj.bigdata.di.module.MessageActivityModule
import com.ewzj.bigdata.mvp.contract.MessageActivityContract
import com.ewzj.bigdata.mvp.presenter.MessageActivityPresenter
import com.jakewharton.rxbinding2.view.RxView
import com.jess.arms.base.BaseActivity
import com.jess.arms.di.component.AppComponent
import kotlinx.android.synthetic.main.activity_message.*
import kotlinx.android.synthetic.main.titile_red.*

class MessageActivity : BaseActivity<MessageActivityPresenter>() ,MessageActivityContract.View{
    override fun setupActivityComponent(appComponent: AppComponent?) {
        DaggerMessageActivityComponent.builder().appComponent(appComponent)
                .messageActivityModule(MessageActivityModule(this))
                .build().inject(this)
    }

    override fun initData(savedInstanceState: Bundle?) {
        swipeRefreshLayout.initcolor()
        mPresenter.initAdapter(rv_msg)
        tv_title.text="我的消息"
        RxView.clicks(iv_back).subscribe({finish()})
        swipeRefreshLayout.setOnRefreshListener { mPresenter.loadFirstPageData() }
        mPresenter.loadFirstPageData()
    }

    override fun initView(savedInstanceState: Bundle?): Int {
        return R.layout.activity_message
    }

    override fun showLoading() {
        swipeRefreshLayout.isRefreshing=true
    }

    override fun launchActivity(intent: Intent?) {
    }

    override fun hideLoading() {
        swipeRefreshLayout.isRefreshing=false
    }

    override fun killMyself() {
    }

    override fun showMessage(message: String?) {
    }

    override fun useFragment(): Boolean {
        return false
    }
}
